import React, { useState } from 'react';
import {ModalForm, ProFormDigit, ProFormRadio, ProFormText, ProFormTextArea} from "@ant-design/pro-form";
import { message } from "antd";
import { distributionTaskLevelUpdate } from "@/services/ant-design-pro/distribution";


const TaskLevelUpdate = (props) => {
  const {record,actionRef } = props

  return (
    <div style={{display:'inline-block'}}>
      <ModalForm
        // visible={modalVisit}
        labelCol={{span: 4}}
        wrapperCol={{span: 14}}
        layout='horizontal'
        title='编辑等级任务'
        trigger={
          <a key="link3"> 编辑 </a>
        }
        onFinish={async (values) => {

          await distributionTaskLevelUpdate(props.record.id,values).then(()=>{
            message.success('修改成功');
          })
          // 刷新
          console.log(actionRef);
          actionRef.current?.reload()
          // actionRef.current.reset();
          return true;
        }}
      >
        <ProFormText
          width="md"
          name="task_type"
          label="任务类型"
          placeholder="请输入任务类型"
          initialValue={record.task_type}
        />
        <ProFormDigit
          width={100}
          name="task_name"
          label="任务名称"
          initialValue={record.task_name}
        />
        <ProFormDigit
          width={100}
          name="limit_num"
          label="限定数量"
          initialValue={record.limit_num}
        />
        {/*任务描述没有这个字段，先注释*/}
        {/*<ProFormTextArea*/}
        {/*  name="miaoshu"*/}
        {/*  label="任务描述"*/}
        {/*  placeholder="请输入任务描述"*/}
        {/*  initialValue='任务描述。。。。'*/}
        {/*/>*/}
        <ProFormDigit
          width={100}
          name="sort"
          label="排序"
          initialValue={record.sort}
        />
        <ProFormRadio.Group
          name="is_show"
          label="是否显示"
          initialValue={record.is_show+''}
          options={[
            {
              label: '显示',
              value: '1',
            },
            {
              label: '隐藏',
              value: '0',
            },
          ]}
        />

      </ModalForm>
    </div>
  );
};

export default TaskLevelUpdate;
